#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"QToolBar"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenuBar* bar=this->menuBar();
    this->setMenuBar(bar);
    QToolBar*toolbar=new QToolBar(this);
    this->addToolBar(toolbar);
    QMenu*menu1=new QMenu("文件");
    bar->addMenu(menu1);
    QAction*action=new QAction("保存");
    menu1->addAction(action);

    toolbar->setAllowedAreas(Qt::LeftToolBarArea);//只能在左侧放置工具栏
    toolbar->addAction(action);//工具栏添加快捷菜单项
    toolbar->setFloatable(false);//不能浮动放置
    QToolBar*toolbar2=new QToolBar(this);
    this->addToolBar(Qt::LeftToolBarArea,toolbar2);
    toolbar2->setMovable(false);//不可移动
    QIcon* icon=new QIcon("C:/Users/x/Pictures/OIP-C.jfif");
    action->setIcon(*icon);
}

MainWindow::~MainWindow()
{
    delete ui;
}

